define(function (require) {
    var Base = require('group/common/main');
    var utils = require('common/utils/home');
    var Mask = require('common/mask');
    var mask = new Mask();

    return Base.extend({
        initialize: function (params) {
            var _this = this;
            Base.prototype.initialize.apply(this, [params]);
            if (_this['page_' + _global.a]) {
                _this['page_' + _global.a]();
            }
        },
        page_index: function () {
            $('#favs').click(function(){
                var favs = $(this);
                var news_id = $(this).data('id');
                utils.ajaxPost(_.extend({'news_id': news_id}, {m: 'favs', a: 'favs'}), function (resp) {
                    mask.error(resp.msg);
                    if(resp.status == 1){
                        mask.success('收藏成功');
                        favs.find('img').attr('src', _global.root + 'app/Tpl/news/public/images/2.png');
                    } else if(resp.status == 2){
                        mask.success('取消成功');
                        favs.find('img').attr('src', _global.root + 'app/Tpl/news/public/images/1.png');
                    } else {
                        mask.error(resp.msg);
                    }
                }, function(resp){
                    mask.error(resp.msg);
                });
            });
        },
    });
});